package org.apache.jsp.totalSearch;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.jsp.*;
import java.util.*;

public final class TotalSearch_jsp extends org.apache.jasper.runtime.HttpJspBase
    implements org.apache.jasper.runtime.JspSourceDependent {

  private static final JspFactory _jspxFactory = JspFactory.getDefaultFactory();

  private static java.util.List _jspx_dependants;

  private javax.el.ExpressionFactory _el_expressionfactory;
  private org.apache.AnnotationProcessor _jsp_annotationprocessor;

  public Object getDependants() {
    return _jspx_dependants;
  }

  public void _jspInit() {
    _el_expressionfactory = _jspxFactory.getJspApplicationContext(getServletConfig().getServletContext()).getExpressionFactory();
    _jsp_annotationprocessor = (org.apache.AnnotationProcessor) getServletConfig().getServletContext().getAttribute(org.apache.AnnotationProcessor.class.getName());
  }

  public void _jspDestroy() {
  }

  public void _jspService(HttpServletRequest request, HttpServletResponse response)
        throws java.io.IOException, ServletException {

    PageContext pageContext = null;
    HttpSession session = null;
    ServletContext application = null;
    ServletConfig config = null;
    JspWriter out = null;
    Object page = this;
    JspWriter _jspx_out = null;
    PageContext _jspx_page_context = null;


    try {
      response.setContentType("text/html; charset=EUC-KR");
      pageContext = _jspxFactory.getPageContext(this, request, response,
      			null, true, 8192, true);
      _jspx_page_context = pageContext;
      application = pageContext.getServletContext();
      config = pageContext.getServletConfig();
      session = pageContext.getSession();
      out = pageContext.getOut();
      _jspx_out = out;

      out.write("\r\n");
      out.write("\r\n");
      out.write("\r\n");
      java.util.Hashtable outputTable = null;
      synchronized (request) {
        outputTable = (java.util.Hashtable) _jspx_page_context.getAttribute("outputTable", PageContext.REQUEST_SCOPE);
        if (outputTable == null){
          outputTable = new java.util.Hashtable();
          _jspx_page_context.setAttribute("outputTable", outputTable, PageContext.REQUEST_SCOPE);
        }
      }
      out.write("\r\n");
      out.write("\r\n");

	ArrayList resultList = (ArrayList)outputTable.get("resultList");
	
	String word = (String)outputTable.get("word");

	ArrayList productSearchList = (ArrayList)resultList.get(0);
	ArrayList bbsSearchList = (ArrayList)resultList.get(1);
	ArrayList priceSearchList = (ArrayList)resultList.get(2);
	
	

      out.write("\r\n");
      out.write("\r\n");
      out.write("<SCRIPT>\r\n");
      out.write("\tfunction moreAction(gubun, word)\r\n");
      out.write("\t{\r\n");
      out.write("\t\tif(gubun == '001')\r\n");
      out.write("\t\t{\r\n");
      out.write("\t\t\twindow.location.href = \"/servlet/service.TotalSearchServlet?func=search_002&word=\"+word;\r\n");
      out.write("\t\t}\r\n");
      out.write("\t\tif(gubun == '002')\r\n");
      out.write("\t\t{\r\n");
      out.write("\t\t\twindow.location.href = \"/servlet/service.TotalSearchServlet?func=search_003&word=\"+word;\r\n");
      out.write("\t\t}\r\n");
      out.write("\t\tif(gubun == '003')\r\n");
      out.write("\t\t{\r\n");
      out.write("\t\t\twindow.location.href = \"/servlet/service.TotalSearchServlet?func=search_001&word=\"+word;\r\n");
      out.write("\t\t}\r\n");
      out.write("\t}\r\n");
      out.write("\t\r\n");
      out.write("</SCRIPT>\r\n");
      out.write("\r\n");
      out.write("\r\n");
      out.write("<TABLE>\r\n");
      out.write("\t<TR height=\"10\"><TD></TD></TR>\r\n");
      out.write("</TABLE>\r\n");
      out.write("<TABLE>\t\r\n");
      out.write("\t\t<tr> \r\n");
      out.write("\t\t\t<td  height=\"30\" bgcolor='f7f7f7' style='padding:0 0 0 15'><img src='image/sub/search_code.gif' align='absmiddle'> &nbsp;&nbsp;&nbsp;현재 통합검색 : <FONT  COLOR=\"#e10000\"><b>");
      out.print(word );
      out.write("</b></FONT> '(으)로 검색하셨습니다.</td> \r\n");
      out.write("\t\t</tr>\r\n");
      out.write("</TABLE>\r\n");
      out.write("\r\n");
      out.write("<TABLE>\r\n");
      out.write("\t<TR>\r\n");
      out.write("\t\t<TD># 상품 검색 ==================================================</TD>\t\t\r\n");
      out.write("\t</TR>\r\n");
      out.write("</TABLE>\r\n");
      out.write("\r\n");
      out.write("\r\n");
      out.write("<TABLE>\r\n");
 
	if(productSearchList.size() == 0)
	{

      out.write("\r\n");
      out.write("\t\t<TR><TD>상품 검색 결과가 없습니다.</TD></TR>\r\n");

	}
	else
	{		
		int count = 0;
		int index = productSearchList.size();
		
		if(index > 5) index = 5;
		
		for(int i=0; i<index ;i++)
		{
			Hashtable productInfo = (Hashtable)productSearchList.get(i);
			String seq = (String)productInfo.get("SEQ");
			String name = (String)productInfo.get("NAME");
			String price = (String)productInfo.get("PRICE");
			String info = (String)productInfo.get("INFO");
			String path = (String)productInfo.get("PATH");
	

      out.write("\t\r\n");
      out.write("\t\t<TR><TD rowspan=\"3\"><IMG width=\"50\" height=\"50\" src=\"");
      out.print(path );
      out.write("\" onclick=\"moreAction(001,'");
      out.print(word );
      out.write("');\"  style=\"cursor:hand\"></IMG></TD><TD>");
      out.print(name );
      out.write("</TD></TR>\r\n");
      out.write("\t\t<TR><TD>");
      out.print(info );
      out.write("</TD></TR>\r\n");
      out.write("\t\t<TR><TD>");
      out.print(price );
      out.write("</TD></TR>\r\n");

		}
		
		if(productSearchList.size()>4)
		{

      out.write("\r\n");
      out.write("\t\t<TR><TD colspan=\"2\" align=\"right\"><A href=\"javascript:moreAction(001, '");
      out.print(word );
      out.write("')\">전체보기</A></TD></TR>\r\n");

		}
	}

      out.write("\r\n");
      out.write("</TABLE>\r\n");
      out.write("\r\n");
      out.write("<TABLE>\r\n");
      out.write("\t<TR>\r\n");
      out.write("\t\t<TD># 리뷰 게시판 검색 ==================================================</TD>\t\t\r\n");
      out.write("\t</TR>\r\n");
      out.write("</TABLE>\r\n");
      out.write("\r\n");
      out.write("<TABLE>\r\n");
 
	if(bbsSearchList.size() == 0)
	{

      out.write("\r\n");
      out.write("\t\t<TR><TD>게시판 검색 결과가 없습니다.</TD></TR>\r\n");

	}
	else
	{		
		int count = 0;
		int index = bbsSearchList.size();
		
		if(index > 5) index = 5;
		
		for(int i=0; i<index ;i++)
		{
			Hashtable bbsInfo = (Hashtable)bbsSearchList.get(i);
			String seq = (String)bbsInfo.get("SEQ");
			String title = (String)bbsInfo.get("TITLE");
			String content = (String)bbsInfo.get("CONTENT");
			String reg_date = (String)bbsInfo.get("REG_DATE");
			String reg_id = (String)bbsInfo.get("REG_ID");
			
			if(content.length()>30) {content = content.substring(0,30)+"...";}
	

      out.write("\t\r\n");
      out.write("\t\t<TR><TD>● ");
      out.print(title );
      out.write(" &nbsp;&nbsp; : ");
      out.print(reg_date );
      out.write("</TD></TR>\r\n");

		}
		
		if(bbsSearchList.size()>4)
		{

      out.write("\r\n");
      out.write("\t\t<TR><TD colspan=\"2\" align=\"right\"><A href=\"javascript:moreAction(002, '");
      out.print(word );
      out.write("')\">전체보기</A></TD></TR>\r\n");

		}
	}

      out.write("\r\n");
      out.write("</TABLE>\r\n");
      out.write("\r\n");
      out.write("\r\n");
      out.write("<TABLE>\r\n");
      out.write("\t<TR>\r\n");
      out.write("\t\t<TD># 가격 검색 ==================================================</TD>\t\t\r\n");
      out.write("\t</TR>\r\n");
      out.write("</TABLE>\r\n");
      out.write("\r\n");
      out.write("<TABLE>\r\n");
 
	if(priceSearchList.size() == 0)
	{

      out.write("\r\n");
      out.write("\t\t<TR><TD>게시판 검색 결과가 없습니다.</TD></TR>\r\n");

	}
	else
	{		
		int count = 0;
		int index = priceSearchList.size();
		
		if(index > 5) index = 5;
		
		for(int i=0; i<index ;i++)
		{
			Hashtable priceInfo = (Hashtable)priceSearchList.get(i);
			String name = (String)priceInfo.get("NAME");
			String price = (String)priceInfo.get("PRICE");
			String info = (String)priceInfo.get("INFO");
			
			
			if(info.length()>30) info = info.substring(0,30)+"...";
	

      out.write("\t\r\n");
      out.write("\t\t<TR><TD>● ");
      out.print(name );
      out.write(" &nbsp;&nbsp; : 가격 : ");
      out.print(price );
      out.write(" 상세 : ");
      out.print(info );
      out.write(" </TD></TR>\r\n");

		}
		
		if(priceSearchList.size()>4)
		{

      out.write("\r\n");
      out.write("\t\t<TR><TD colspan=\"2\" align=\"right\"><A href=\"javascript:moreAction(003, '");
      out.print(word );
      out.write("')\">전체보기</A></TD></TR>\r\n");

		}
	}

      out.write("\r\n");
      out.write("</TABLE>\r\n");
      out.write("\r\n");
      out.write("\r\n");
      out.write("\r\n");
      out.write("\r\n");
      out.write("\r\n");
      out.write("\r\n");
      out.write("\r\n");
      out.write("\r\n");
      out.write("\r\n");
      out.write("\r\n");
      out.write("\r\n");
      out.write("\r\n");
    } catch (Throwable t) {
      if (!(t instanceof SkipPageException)){
        out = _jspx_out;
        if (out != null && out.getBufferSize() != 0)
          try { out.clearBuffer(); } catch (java.io.IOException e) {}
        if (_jspx_page_context != null) _jspx_page_context.handlePageException(t);
      }
    } finally {
      _jspxFactory.releasePageContext(_jspx_page_context);
    }
  }
}
